package com.hs;

import android.graphics.Bitmap;
import android.graphics.Color;

/************************************
 *@desc：这是功能描述...
 *@Author: admin
 *@DateTime:2023/10/17 17:30
 *@Copyright: hskj
 *************************************/
public class ZaFingerBitmapUtils {
    /**
     * @param image
     * @param width
     * @param height  这个值要使用数据总长度
     * @return
     */
    public static Bitmap getFingerBitmap(byte[] image, int width, int height) {
        if (width==0) return null;
        if (height==0) return null;
        if (image == null) return null;
        if (image.length < width*height){
            height = (int)image.length / width;
        }

        int[] RGBbits = new int[width * height];
        for (int i = 0; i < width * height; i++ ) {
            int v;
            int red = 0;
            if (image != null) {
                v = image[i] & 0xff;
            } else {
                v = 0;
            }
            red = v;
            if(v<200)
                RGBbits[i] = Color.argb(255,red, v, v);
            else
                RGBbits[i] = Color.argb(0,red, v, v);
        }
        Bitmap bmp = Bitmap.createBitmap(RGBbits, width, height, Bitmap.Config.ARGB_8888);
        return bmp;
    }
}
